package org.nepu.scr.indexrate.vo.drillingrate.keydevice.fixedcontrolsystem.fixedcontrolsystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.fixedcontrolsystem.FixedControlDevice;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class FixedControlDeviceConverter implements AttributeConverter<FixedControlDevice, String> {
    @Override
    public String convertToDatabaseColumn(FixedControlDevice fixedControlDevice) {
        return JSONUtil.toJsonStr(fixedControlDevice);
    }

    @Override
    public FixedControlDevice convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, FixedControlDevice.class);
    }
}
